package org.example.springbootproject.dto;

import lombok.Data;
import org.example.springbootproject.entity.ExamPaper;
import org.example.springbootproject.entity.PaperQuestion;
import org.example.springbootproject.entity.Question;

import java.util.List;

@Data
public class PaperDetailDTO {

    private Long id;
    private String name;
    private Integer totalScore;
    private Integer passScore;
    private List<QuestionInfo> questions;

    @Data
    public static class QuestionInfo {
        private Long id;
        private String type;
        private String content;
        private String options; // JSON 字符串
        private Integer score;

        public QuestionInfo(PaperQuestion paperQuestion, Question question) {
            this.id = question.getId();
            this.type = question.getType();
            this.content = question.getContent();
            this.options = question.getOptions();
            this.score = paperQuestion.getScore();
        }
    }

    public PaperDetailDTO(ExamPaper examPaper, List<QuestionInfo> questionInfos) {
        this.id = examPaper.getId();
        this.name = examPaper.getName();
        this.totalScore = examPaper.getTotalScore();
        this.passScore = examPaper.getPassScore();
        this.questions = questionInfos;
    }
}
